package dtd.PHS.VND_ExchangeRate.data;

import java.util.ArrayList;

import dtd.PHS.VND_ExchangeRate.utils.Helpers;

public class ListRates extends ArrayList<RateItem> {
	private static final long serialVersionUID = 6601228589751439605L;
	private static final String CURR_ORDER = "USD,EUR,AUD,CAD,CHF,GBP,HKD,JPY,SGD,THB"; 
	public static ListRates reorder(ListRates listRates) {
		ArrayList<String> words = Helpers.split(CURR_ORDER,","); 
		ListRates newList = new ListRates();
		for(String cname : words) {
			for(RateItem item : listRates) {
				if ( item.getCurrencyName().toLowerCase().equals(cname.toLowerCase())) {
					newList.add(item);
				}
			}
		}
		return newList;
	}
	public RateItem getRate(String currencyName) {
		for(RateItem item : this) {
			if (item.getCurrencyName().toLowerCase().trim().equals(currencyName.toLowerCase().trim())) {
				return item;
			}
		}
		return null;
	}
}
